package UnitTest;

/**
 * @Auther: Administrator
 * @Date: 2019/8/24/024 19 44
 * @Description:
 */

public class SimpleFactory {

    public static void main(String[] args) {
        Car car = new SimpleFactory().getCar("BMW");
        System.out.println(car.getName());
    }


    public Car getCar(String name){
        if("BMW".equalsIgnoreCase(name)){
            return new Bmw();
        }else{
            System.out.println("这个产品产不出来");
            return null;
        }
    }

}

interface Car {

    //规定汽车的品牌
    String getName();

}

class Bmw implements Car{

    @Override
    public String getName() {
        return "BMW";
    }

}


